<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="UTF-8">
    <script type="text/javascript" src="../assets/js/vue.js"></script>
    <title>Mixins 混入选项操作</title>
</head>

<body>
    <h1>Mixins 混入选项操作</h1>
    <hr>
    <div id="app">
        <p>{{num}}</p>
        <p><button @click="add">Add</button></p>
    </div>
    <script type="text/javascript">
        //额外临时加入时，用于显示日志
        var addLog = {
            updated: function () {
                console.log("数据放生变化,变化成" + this.num + ".");
            }
        }
        Vue.mixin({
            updated: function () {
                console.log('我是全局被混入的,变化成'+ this.num + ".");
            }
        })
        var app = new Vue({
            el: '#app',
            data: {
                num: 1
            },
            methods: {
                add: function () {
                    this.num++
                }
            },
            mixins: [addLog] //混入
        });
      
    </script>
</body>

</html>